# test.py

from pydicom.fileio.leanread import dicomfile

import sys
filename = sys.argv[1]
target_group = int(sys.argv[2], 16)
target_elem = int(sys.argv[3], 16)

usage = """python testfind.py filename group_hex elem_hex"""

with dicomfile(filename) as f:
    target_tag = (target_group, target_elem)
    target_val = None
    for data_elem in f:
        tag = data_elem[0]
        if tag >= target_tag:
            if tag == target_tag:
                target_val = data_elem[3]
            break
print(filename + ":" + repr(target_val))